package yxy.cherry.battle.module.affix.buff;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixContext.AffixTarget;
import yxy.cherry.battle.module.affix.AffixFactory.BuffTypeEnum;
import yxy.cherry.battle.module.affix.Buff;
import yxy.cherry.battle.module.affix.BuffType;
import yxy.cherry.data.bean.skill;

/** 减疗 */
@BuffType(Type = BuffTypeEnum.减疗)
public class Affix_63_减疗 extends Buff {

	private int get减疗比例() {
		return getParam(0);
	}

	public Affix_63_减疗(Fighter source, Fighter target, skill skilldata, int[] params) {
		super(source, target, skilldata, params);
	}

	@Override
	public boolean exec(Fighter source, Fighter actor) {
		AffixTarget affixTarget = getAffixContext().get治疗行动().getTarget(actor);
		if (affixTarget == null) {
			return false;
		}

		long 治疗量 = affixTarget.get治疗量();
		if (治疗量 <= 0) {
			return false;
		}

		治疗量 -= 治疗量 * get减疗比例() / VALUE_比率分母;
		Battle.battleLogger(6,"减疗：被治疗者："+affixTarget.get目标().getName()+"原始治疗量："+affixTarget.get治疗量()+"减疗比例："+get减疗比例()+"治疗量："+治疗量);
		affixTarget.set治疗量(治疗量);

		return true;
	}

	@Override
	public BuffType getBuffType() {
		return BuffType.减益效果;
	}

	@Override
	public BuffStateType getBuffStateType() {
		return BuffStateType.减疗状态;
	}
}